<?php


namespace app\api\model\card;


use app\common\model\CourseOrder;
use think\Db;

class Order extends CourseOrder
{
    /**
     * 获取订单详情(待付款状态)
     * @param $orderNo
     * @return self|null
     * @throws \think\exception\DbException
     */
    public static function getPayDetail($orderNo)
    {
        return self::detail(['order_no' => $orderNo, 'pay_status' => 10]);
    }

    /**
     * @title 支付成功的列表
     * @param $userId
     * @author Qian
     * Time: 2023/2/28  0:11
     */
    public function getList($userId)
    {
        // 获取列表数据
        $list = $this->with(['orderdetail','image.file'])->where('user_id', '=', $userId)
            ->where('pay_status', '=', 20)
            ->order(['create_time' => 'desc'])
            ->paginate(15, false, [
                'query' => request()->request()
            ]);
        foreach ($list as $k=>$v){
            $detail = Db::name('course_order_detail')->where(['order_id'=>$v['order_id']])->find();
            $list[$k]['detail'] = $detail;
        }
        return $list;
    }
}